<script>
  import tree from '@/mixins/tree/index.js'
  import AjaxStore from '@/utils/store/proxyAjax'
  import store from '../store.js'
  import { validateNumber } from '@/utils/validate'
  import FormPanel from '@/components/FormPanel'
  import addtable from '@/mixins/addtable'
  import { getUserInfo } from '@/utils/auth'

export default {
    name: 'menuconfig',
    tag: 'noKeepalive',
    mixins: [tree, store, addtable],
    components: { FormPanel },
    data() {
      const validateOrderNo = (rule, value, callback) => {
        if (value && !validateNumber(value)) {
          callback(new Error('请输入正整数'))
        } else {
          callback()
        }
      }
      return {
        editPid: '',
        pidLabel: '',
        funName: '',
        file: '',
        fileList: [],

        labelWidth: '100px',

        tree: {
          width: "280",
          accordion: false,
          isShowHeader: true,
          treeMenuButtonList: this.treeMenuBtns,
          treeOperateButtonList: this.treeOperateBtns,
          search: {
            searchKey: 'nodeName'
          },
          showCheckbox: false,
          selectTree: {},
          nextNodeKey: 'node',
          idKey: 'funId',
          title: `${getUserInfo().project.projectName} - 菜单树`,
          getNextChildNode: this.getNextNode,
          delNode: this.delNode
        },

        nodeIdKey: 'id',
        nodeLabelKey: 'text',
        pidKey: 'pid',
        idKey: 'funId',
        labelKey: 'funName',
        currentNode: null,
        panelType: '',
        locationData: '',
        formLoading: false,

        acceptFileType: '.xls,.xlsx',

        addNodeInfoUrl: '/v1/yq/projectfunction/add',
        updateNodeInfoUrl: '/v1/yq/projectfunction/update',
        getNextNodeUrl: '/v1/yq/projectfunction/findNextChildNodeTree',
        delNodeUrl: '/v1/yq/projectfunction/deleteNode',
        getNodeInfoUrl: '/v1/yq/projectfunction/findByFunIdAndProjectId',
        importUrl: "/v1/yq/projectfunction/importProjectFunction",
        store: new AjaxStore({
          url: '/v1/yq/projectdefaultfunction/query'
        }),

        formPanel: {
          add: {
            model: {
              "funId": '',
              "funName": '',
              "funType": '',
              "location": '',
              "pid": '',
              "orderNo": '',
              "helpUrl": '',
              "openNew": false,
              "logFlag": 0,
              "icon": '',
              "version": '',
              "remark": '',
              "fullPath": ''
            },
            fields: [
              { label: '父菜单', prop: 'pid', anchor: 24, xType: 'SelectTree.TREE', ref: 'addPid', relatedFields: ['addFunPath'],
                treeParams: {
                  get: {
                    getNextNode: this.getFunctionTree
                  }
                },
                valueToLabelParams: {
                  url: `/v1/yq/projectfunction/findFunName?projectId=${getUserInfo().project.projectId}`,
                  idKey: 'funId'
                },
                on: {
                  'visible-change': val => val && this.$refs.addForm.$refs.addPid.reload()
                }
              },
              { label: '菜单类型', prop: 'funType', xType: 'SelectCode.FUN_TYPE', placeholder: '选择菜单类型', anchor: 24, relatedFields: ['addHelpUrl', 'addOpenNew'] },
              // { label: '菜单编码', prop: 'funId', placeholder: '输入菜单编码', anchor: 24 },
              { label: '菜单名称', prop: 'funName', placeholder: '输入菜单名称', anchor: 24,
                on: {
                  input: (val) => {
                    this.funName = val
                    if (!this.formPanel.add.model.pid) {
                      this.formPanel.add.model.fullPath = this.filterArray([this.funName]).join('/')
                    } else {
                      const selectPidLabel = this.$refs.addForm.$refs.addPid.selectedLabel
                      this.formPanel.add.model.fullPath = this.filterArray([this.getFrontStr(this.fullPath, selectPidLabel), this.funName]).join('/')
                    }
                  }
                }
              },
              { label: '链接', prop: 'location', placeholder: '输入链接', anchor: 24 },
              // { label: '菜单地址', prop: 'location', anchor: 24, xType:'custom', ref: 'location',
              //   render: function(h, opts) {
              //   return (
              //     <c-select
              //       filterable={true}
              //       remote={true}
              //       placeholder='请输入或选择菜单地址'
              //       loading={this.formLoading}
              //       value={ this.formPanel.add.model.location }
              //       {...{
              //         on: {
              //           focus: () => {
              //             this.getLocationData(true)
              //           },
              //           blur: e => {
              //             this.formPanel.add.model.location = e.target.value
              //           },
              //           change: opts.on.change
              //         }
              //       }}
              //       remoteMethod={ val => this.getLocationData(false, val) }
              //     >
              //       {
              //         this._l(this.locationData, item => {
              //         return (
              //         <c-option
              //         key={ item }
              //         label={ item }
              //         value={ item }
              //         >
              //         </c-option>
              //         )
              //         })
              //       }
              //     </c-select>
              //   )}.bind(this._renderProxy, this.$createElement)
              // },
              { label: '排序号', prop: 'orderNo', placeholder: '输入排序号', anchor: 24 },
              { label: '帮助页Url', prop: 'helpUrl', placeholder: '输入帮助页Url', ref: 'addHelpUrl', anchor: 24, class: 'help-url',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    const helpUrlFormItem = document.getElementsByClassName('help-url')[0].parentNode.parentNode
                    form.model.helpUrl = ''
                    if (form.model.funType === 2) {
                      helpUrlFormItem.classList.remove('menu-item-display-none')
                      this.labelWidth = '170px'
                    } else {
                      this.labelWidth = '100px'
                      helpUrlFormItem.classList.add('menu-item-display-none')
                    }
                  }
                }
              },
              { label: '是否以新窗口的方式打开', prop: 'openNew', xType: 'switch', ref: 'addOpenNew', anchor: 24, "active-value": true, "inactive-value": false, class: 'open-new',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    const openNewFormItem = document.getElementsByClassName('open-new')[0].parentNode.parentNode
                    form.model.openNew = false
                    if (form.model.funType === 2) {
                      this.labelWidth = '170px'
                      openNewFormItem.classList.remove('menu-item-display-none')
                    } else {
                      this.labelWidth = '100px'
                      openNewFormItem.classList.add('menu-item-display-none')
                    }
                  }
                }
              },
              { label: '是否记日志', prop: 'logFlag', xType: 'switch', anchor: 24, "active-value": 1, "inactive-value": 0 },
              { label: '图标', prop: 'icon', placeholder: '输入图标', anchor: 24 },
              { label: '备注', prop: 'remark', placeholder: '输入备注', type: "textarea", rows: 2, anchor: 24 },
              { label: '全路径', prop: 'fullPath', anchor: 24, readonly: true, style: 'border: 0;', ref: 'addFunPath',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    if (form.model.pid) {
                      this.getNodeInfo({ funId: form.model.pid, projectId: this.projectId }).then(({ success, data }) => {
                        if (success && data.fullPath) {
                          // 获取上级机构全路径
                          this.fullPath = data.fullPath
                          this.formPanel.add.model.fullPath = this.filterArray([this.getFrontStr(this.fullPath, origin.selectedLabel), form.model.funName]).join('/')
                        }
                      })
                    } else {
                      form.model.fullPath = this.filterArray([form.model.funName]).join('/')
                    }
                  }
                }
              }
            ],
            rules: {
              "funId": [{ required: true, message: '请输入菜单编码', trigger: 'blur' }],
              "funName": [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
              "funType": [{ required: true, message: '请输入菜单类型', trigger: 'change' }],
              "orderNo": [{ validator: validateOrderNo, trigger: 'blur' }]
            },
            title: '新增站点菜单',
            type: 'ADD',
            ref: 'addForm',
            submitBtnList: this.addBtns
          },
          edit: {
            model: {
              "funId": '',
              "funName": '',
              "funType": '',
              "location": '',
              "pid": '',
              "orderNo": '',
              "helpUrl": '',
              "openNew": false,
              "logFlag": 0,
              "icon": '',
              "version": '',
              "remark": '',
              "fullPath": ''
            },
            fields: [
              { label: '父菜单', prop: 'pid', anchor: 24, xType: 'SelectTree.TREE', ref: 'editPid', relatedFields: ['editFunPath'],
                on: {
                  'update': (val, vnode, form) => {
                    const selfId = this.editPid
                    const $tree = vnode.$refs.tree
                    const path = $tree.getNodePath(val) || []
                    for (let i = 0, len = path.length; i < len; i++) {
                      if (selfId === path[i]['id']) {
                        form.model.pid = ''
                        this.$message({
                          type: 'error',
                          message: '父菜单不能选择自身或自己的子节点！'
                        })
                        break
                      }
                    }
                  },
                  'visible-change': val => val && this.$refs.editForm.$refs.editPid.reload()
                },
                // 下拉树参数
                treeParams: {
                  get: {
                    getNextNode: this.getFunctionTree
                  }
                },
                valueToLabelParams: {
                  url: `/v1/yq/projectfunction/findFunName?projectId=${getUserInfo().project.projectId}`,
                  idKey: 'funId'
                }
              },
              { label: '菜单类型', prop: 'funType', xType: 'SelectCode.FUN_TYPE', placeholder: '选择菜单类型', anchor: 24, relatedFields: ['editHelpUrl', 'editOpenNew'] },
              // { label: '菜单编码', prop: 'funId', placeholder: '输入菜单编码', anchor: 24, disabled: true },
              { label: '菜单名称', prop: 'funName', placeholder: '输入菜单名称', anchor: 24,
                on: {
                  input: (val) => {
                    this.funName = val
                    if (!this.formPanel.edit.model.pid) {
                      this.formPanel.edit.model.fullPath = this.filterArray([this.funName]).join('/')
                    } else {
                      const selectPidLabel = this.$refs.editForm.$refs.editPid.selectedLabel
                      this.formPanel.edit.model.fullPath = this.filterArray([this.getFrontStr(this.fullPath, selectPidLabel), this.funName]).join('/')
                    }
                  }
                }
              },
              { label: '链接', prop: 'location', placeholder: '输入链接', anchor: 24 },
              // { label: '菜单地址', prop: 'location', anchor: 24, xType:'custom', ref: 'location',
              //   render: function(h, opts) {
              //   return (
              //     <c-select
              //       filterable={true}
              //       remote={true}
              //       placeholder='请输入菜单地址'
              //       loading={this.formLoading}
              //       value={ this.formPanel.edit.model.location }
              //       {...{
              //         on: {
              //           focus: () => {
              //             this.getLocationData(true)
              //           },
              //           blur: e => {
              //             this.formPanel.edit.model.location = e.target.value
              //           },
              //           change: opts.on.change
              //         }
              //       }}
              //       remoteMethod={ val => this.getLocationData(false, val) }
              //     >
              //       {
              //         this._l(this.locationData, item => {
              //         return (
              //         <c-option
              //         key={ item }
              //         label={ item }
              //         value={ item }
              //         >
              //         </c-option>
              //         )
              //         })
              //       }
              //     </c-select>
              //   )}.bind(this._renderProxy, this.$createElement)
              // },
              { label: '排序号', prop: 'orderNo', placeholder: '输入排序号', anchor: 24 },
              { label: '帮助页Url', prop: 'helpUrl', placeholder: '输入帮助页Url', ref: 'editHelpUrl', anchor: 24, class: 'help-url',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    const helpUrlFormItem = document.getElementsByClassName('help-url')[0].parentNode.parentNode
                    form.model.helpUrl = ''
                    if (form.model.funType === 2) {
                      helpUrlFormItem.classList.remove('menu-item-display-none')
                      this.labelWidth = '170px'
                    } else {
                      this.labelWidth = '100px'
                      helpUrlFormItem.classList.add('menu-item-display-none')
                    }
                  }
                }
              },
              { label: '是否以新窗口的方式打开', prop: 'openNew', xType: 'switch', ref: 'editOpenNew', anchor: 24, "active-value": true, "inactive-value": false, class: 'open-new',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    const openNewFormItem = document.getElementsByClassName('open-new')[0].parentNode.parentNode
                    if (form.model.funType === 2) {
                      this.labelWidth = '170px'
                      openNewFormItem.classList.remove('menu-item-display-none')
                    } else {
                      this.labelWidth = '100px'
                      openNewFormItem.classList.add('menu-item-display-none')
                    }
                  }
                }
              },
              { label: '是否记日志', prop: 'logFlag', xType: 'switch', anchor: 24, "active-value": 1, "inactive-value": 0 },
              // { label: '是否记日志', prop: 'logFlag', xType: 'SelectCode.IF', placeholder: '输入是否记日志', anchor: 24 },
              { label: '图标', prop: 'icon', placeholder: '输入图标', anchor: 24 },
              { label: '备注', prop: 'remark', placeholder: '输入备注', type: "textarea", rows: 2, anchor: 24 },
              { label: '全路径', prop: 'fullPath', anchor: 24, readonly: true, style: 'border: 0;', ref: 'editFunPath',
                on: {
                  'el.form.update': (val, ctx, origin, form) => { // 值,当前组件,关联组件
                    if (form.model.pid) {
                      this.getNodeInfo({ funId: form.model.pid, projectId: this.projectId }).then(({ success, data }) => {
                        if (success && data.fullPath) {
                          // 获取上级机构全路径
                          this.fullPath = data.fullPath
                          this.formPanel.edit.model.fullPath = this.filterArray([this.getFrontStr(this.fullPath, origin.selectedLabel), form.model.funName]).join('/')
                        }
                      })
                    } else {
                      form.model.fullPath = this.filterArray([form.model.funName]).join('/')
                    }
                  }
                }
              }
            ],
            rules: {
              "funId": [{ required: true, message: '请输入菜单编码', trigger: 'blur' }],
              "funName": [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
              "funType": [{ required: true, message: '请输入菜单类型', trigger: 'change' }],
              "orderNo": [{ validator: validateOrderNo, trigger: 'blur' }]
            },
            title: '编辑站点菜单',
            type: 'EDIT',
            ref: 'editForm',
            submitBtnList: this.editBtns
          }
        }
      }
    },
    computed: {
      projectId() {
        console.log(getUserInfo())
        return getUserInfo().project.projectId
      },
      projectName() {
        console.log(getUserInfo())

        return "123"
      }
    },
    methods: {
      handleTreeImport() {
        this.$confirm('导入后会覆盖原有数据，是否继续？', '提示', {
          cancelButtonText: '取消',
          confirmButtonText: '确定',
          type: 'warning'
        }).then(() => {
          this.$refs.upload.$refs['upload-inner'].$refs.input.click()
        })
      },
      handleFileChange(file, fileLists) {
        this.fileList = []
        for (var i = 0; i < fileLists.length; i++) {
          this.fileList.push(fileLists[i].raw)
        }
        // 取出相同文件的文件名
        var files = this.fileList
        for (let i = 0; i < files.length; i++) {
          const fileName = files[i].name
          for (let j = 0; j < files.length; j++) {
            /* eslint-disable-next-line */
            if (fileName === files[j].name && !i == j) {
              this.$message({
                type: 'error',
                message: '请勿上传相同的文件'
              })
            }
          }
        }
        this.file = file.raw
      },
      renderCustom() {
        return [
          <c-upload
            class="upload-file"
            ref="upload"
            auto-upload={ true }
            action="/v1/yq/projectfunction/import"
            accept={ this.acceptFileType }
            list-type="picture"
            name="file"
            limit={1}
            {
            ...{
              props: {
                onChange: this.handleFileChange,
                httpRequest: this.handleHttpRequest
              // onSuccess: this.handleFileSuccess,
              // onError: this.handleFileError
              }
            }
            }
          >
          </c-upload>
        ]
      },
      handleHttpRequest() {
        const formData = new FormData()
        formData.append('file', this.file)
        const that = this
        return new Promise((resolve, reject) => {
          return that.import(formData, that.importUrl).then(({ success, message }) => {
            that.$message({
              type: success ? 'success' : 'error',
              message
            })
            that.$refs.upload.fileList && that.$refs.upload.fileList.splice(0)
            if (success) {
              that.$refs.tree.load()
              return resolve(true)
            } else {
              throw new Error(message)
            }
          })
            .catch(err => {
              that.$refs.upload.fileList && that.$refs.upload.fileList.splice(0)
              console.log(err)
              return reject(err)
            })
        })
      },
      getLocationData(focusFlag, val) {
        this.formLoading = true
        return this.request({
          url: '/v1/yq/projectfunction/findAllLocationByProject',
          method: 'get'
        }).then(({ data }) => {
          if (focusFlag) {
            this.locationData = data
            this.formLoading = false
          } else {
            const arr = data.filter(item => item.indexOf(val) > -1)
            if (arr.length > 0) {
              this.locationData = arr
              this.formLoading = false
            } else {
              this.locationData = []
              this.formLoading = false
              this.$refs.addForm && (this.formPanel.add.model.location = val)
              this.$refs.editForm && (this.formPanel.edit.model.location = val)
            }
          }
        })
      },
      getFrontStr(str, reg) {
        return str.split(reg)[0] + reg
      },
      getNextNode(params, url = this.getNextNodeUrl) {
        params = params || {}
        // delete params.node
        params.projectId = this.projectId
        return this.request({
          url,
          method: 'get',
          params
        })
      },
      delNode(params, url = this.delNodeUrl) {
        params = params || {}
        params.projectId = this.projectId
        return this.request({
          url,
          method: 'post',
          headers: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          data: params
        })
      },
      getFunctionTree(params, data) {
        if (data) params.node = data['id']
        params.projectId = this.projectId
        return this.request({
          url: "/v1/yq/projectfunction/findNextChildNodeTree",
          method: 'get',
          params
        })
      },
      handleNodeEdit(node) {
        node && (this.currentNode = node)

        this.dialogType = this.formPanel.edit.type

        const params = {}
        params[this.idKey] = node.data[this.nodeIdKey]
        params["projectId"] = this.projectId
        this.getNodeInfo(params).then(({ data }) => {
          data.fullPath && (this.fullPath = data.fullPath)
          this.$refs.editForm && this.$refs.editForm.resetFields()
          Object.keys(this.formPanel.edit.model).forEach(key => {
            this.$set(this.formPanel.edit.model, key, '')
          })
          Object.assign(this.formPanel.edit.model, data)
          this.$nextTick(() => {
            this.$refs.editForm.clearValidate()
            const helpUrlFormItem = document.getElementsByClassName('help-url')[0].parentNode.parentNode
            const openNewFormItem = document.getElementsByClassName('open-new')[0].parentNode.parentNode
            if (data['funType'] !== 2) {
              this.labelWidth = "100px"
              helpUrlFormItem.classList.add('menu-item-display-none')
              openNewFormItem.classList.add('menu-item-display-none')
            } else {
              this.labelWidth = "170px"
              helpUrlFormItem.classList.remove('menu-item-display-none')
              openNewFormItem.classList.remove('menu-item-display-none')
            }
          })
          this.renderTreeCheckCallback()
        })
      },
      handleFormAdd() {
        return this.$refs.addForm.validate()
          .then(() => {
            let params = {}
            params = Object.assign({ projectId: this.projectId }, this.formPanel.add.model)
            if (params.funType !== 2) {
              delete params.helpUrl
              delete params.openNew
            }
            return this.addNodeInfo(params)
          })
          .then(({ success }) => {
            this.$message({
              type: success ? 'success' : 'error',
              message: success ? '添加项目站点菜单成功！' : '添加项目站点菜单失败！'
            })
            if (success) {
              this.addLocalTree(this.formPanel.add.model)
            } else {
              throw new Error('添加项目站点菜单失败！')
            }
          })
          .catch(err => {
            console.log(err)
            return Promise.reject(err)
          })
      },
      /**
       * 点击页面右侧 树节点信息编辑表单面板 保存按钮 触发
       *  - 模板中该方法会执行：
       *    -- 发送编辑请求，发送 树节点信息编辑表单绑定数据 model:
       *       ---- 编辑发送成功，则提示成功信息，执行 editLocalTree(this.formPanel.edit.model)，对左侧 tree 本地进行编辑树节点操作
       *       ---- 编辑失败，则提示失败信息
      */
      handleFormEdit() {
        return this.$refs.editForm.validate()
          .then(() => {
            let params = {}
            params = Object.assign(params, this.formPanel.edit.model)
            if (params.funType !== 2) {
              delete params.helpUrl
              delete params.openNew
            }
            if (!this.formPanel.edit.model.pid) {
              delete params.pid
            }
            return this.updateNodeInfo(params)
            // return this.updateNodeInfo(Object.assign({ projectId: this.projectId }, this.formPanel.edit.model))
          })
          .then(({ success }) => {
            this.$message({
              type: success ? 'success' : 'error',
              message: success ? '修改项目站点菜单成功！' : '修改项目站点菜单失败！'
            })
            if (success) {
              this.editLocalTree(this.formPanel.edit.model)
            } else {
              throw new Error('修改项目站点菜单失败！')
            }
          })
          .catch(err => {
            console.log(err)
            return Promise.reject(err)
          })
      },
      addLocalTree(data) {
        // 没有添加父节点，直接刷新树
        if (!data[this.pidKey]) {
          this.$refs.tree.refresh()
        } else {
          // 在当前树中查找父节点
          const pNode = this.$refs.tree.getNodeById(data[this.pidKey])
          if (pNode) {
            // 找到就添加并展开下拉
            this.$refs.tree.handleNodeExpand(pNode.data, true).then(() => {
              // 有可能后端没有这么快能生成对应节点
              if (this.$refs.tree.getNodeById(data[this.IdKey])) {
                const node = this.$refs.tree.getNodeById(data[this.IdKey])
                this.$refs.tree.setCurrentNodeById(data[this.IdKey])
                this.handleNodeEdit(node)
              } else {
                this.currentNode && this.handleNodeEdit(this.currentNode)
              }
            })
          } else {
            // 因为分步加载，没找到直接刷新
            this.$refs.tree.refresh()
          }
        }
        this.renderAddLocalTreeCallback(data)
      },
      // eslint-disable-next-line
      renderFormPanel(h) {
        return this._l(this.formPanel, (item) => {
          if (this.dialogType === item.type) {
            return (
              <FormPanel
                key={ item.type }
                class="c-form-common"
                ref={ item.ref }
                items={ item.fields }
                inline={false}
                props-model={ item.model }
                labelWidth={ this.labelWidth }
                rules={ item.rules }>
                <div class="el-form-header" slot="title">
                  {item.title}
                </div>
                <c-form-item class="submit-btn">
                  <ButtonList operateBtnList={ item.submitBtnList } />
                </c-form-item>
              </FormPanel>
            )
          }
        })
      }
    },
    // eslint-disable-next-line
    render(h) {
      return (
        <div class="menuconfig two-columns">
          <div class="left">
            {
              this.renderTree(h)
            }
          </div>
          <div class="right treePanel">

            {
              this.renderFormPanel(h)
            }
          </div>
          {
            this.renderCustom(h)
          }
        </div>
      )
    },
    beforeCreate() {
      // 根据页面路由找出有权限访问的 url 数组
      const urlArr = (this.$route.meta && this.$route.meta.children || []).map(item => item.url)
      console.log(urlArr)

      // 根据权限 url 数组过滤出能够使用的 按钮数组
      this.addBtns = [
        { label: '保存', methods: 'handleFormAdd', url: '/v1/yq/projectfunction/add', icon: 'el-icon-circle-check-outline', type: 'primary', disabled: false }
      ].filter(item => (item.url && urlArr.includes(item.url)) || !item.url)

      this.editBtns = [
        { label: '保存', methods: 'handleFormEdit', url: '/v1/yq/projectfunction/update', icon: 'el-icon-circle-check-outline', type: 'primary', disabled: false }
      ].filter(item => (item.url && urlArr.includes(item.url)) || !item.url)

      this.treeMenuBtns = [
        { label: '新增', methods: 'handleMenuAdd', url: '/v1/yq/projectfunction/add', icon: 'el-icon-circle-plus-outline', type: 'text', action: 'plus' },
        { label: '导入', methods: 'handleImport', url: '/v1/yq/projectfunction/import', icon: 'el-icon-document', type: 'text' },
        { label: '刷新', methods: 'refresh', url: '/v1/yq/projectfunction/add', icon: 'el-icon-refresh', type: 'text' },
        { label: '展开', methods: 'expand', url: '/v1/yq/projectfunction/add', icon: 'el-icon-rank', type: 'text' },
        { label: '折叠', methods: 'fold', url: '', icon: 'el-icon-arrow-up', type: 'text' }
      ].filter(item => (item.url && urlArr.includes(item.url)) || !item.url)

      this.treeOperateBtns = [
        { type: 'text', url: '/v1/yq/projectfunction/add', icon: 'el-icon-plus', action: 'plus' },
        { type: 'text', url: '/v1/yq/projectfunction/deleteNode', icon: 'el-icon-delete', action: 'delete' }
      ].filter(item => (item.url && urlArr.includes(item.url)) || !item.url)
    }
  }
</script>

<style lang="scss">
.menuconfig {
  .right {
    .submit-btn {
      display: flex;
      justify-content: flex-end;
    }
  }
}
.menu-item-display-none {
  display: none;
}
</style>
